package com.milloc.db.config;

import com.milloc.db.service.SQLRunnerService;
import com.milloc.db.service.SQLService;
import com.milloc.db.service.ScriptRunnerService;
import com.milloc.db.wrapper.RunnerWrapper;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;

/**
 * @author gongdeming
 * @create 2019-08-27
 */
//@Configuration
public class ScriptConfig {
    private final SQLRunnerService aSQLRunnerService;
    private final ScriptRunnerService scriptRunnerService;

    public ScriptConfig(SQLRunnerService aSQLRunnerService, ScriptRunnerService scriptRunnerService) {
        this.aSQLRunnerService = aSQLRunnerService;
        this.scriptRunnerService = scriptRunnerService;
    }

//    @Bean
//    @Qualifier("JS")
//    public ScriptEngine getJSScriptEngine() {
//        ScriptEngine js = new ScriptEngineManager().getEngineByName("js");
//        js.put("$", new RunnerWrapper(aSQLRunnerService, scriptRunnerService));
//        return js;
//    }
}
